package work.MrSun.xyq.controller;

/**
 * @Author MrSun
 * @Date 2023/4/17 15:31
 */

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import work.MrSun.xyq.model.XyqMessage;
import work.MrSun.xyq.service.XyqMessageDetailService;
import work.MrSun.xyq.service.XyqMessageImagesService;
import work.MrSun.xyq.service.XyqUserService;
import work.MrSun.xyq.util.Upload.IsUpload;
import work.MrSun.xyq.util.isUpdate.IsUpdate;

/**
 * 发布---控制层
 */
@RestController
public class AddMessageDetailController {
    @Autowired
    private XyqMessageImagesService xyqMessageImagesService;

    @Autowired
    private XyqMessageDetailService xyqMessageDetailService;

    @Autowired
    private XyqUserService xyqUserService;

    @Transactional
    @PostMapping("/addMessage/{userId}")
    public IsUpload addMessage(@PathVariable Integer userId, @RequestBody XyqMessage xyqMessage) {
        return new IsUpload().isTrue(xyqMessage, xyqMessageDetailService, xyqMessageImagesService, xyqUserService);
    }

}
